﻿<%@ page language="java" import="java.util.*,java.sql.*,Pluto.function"
pageEncoding="UTF-8"%>
<jsp:useBean id="conn" class="Pluto.DBConnection" scope="session" />

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>daily</title>
    <meta name="keywords" content="" />
		<meta name="description" content="" />
		
	<script type="text/javascript" src="js/calender.js"></script>
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/nicejforms.js"></script>
	<script type="text/javascript" src="js/thickbox.js"></script>
	<script type="text/javascript" src="js/audioplayer.js"></script>
	<link href="css/default.css" rel="stylesheet" type="text/css" />
	<link href="css/page.css" rel="stylesheet" type="text/css" />
	<link href="css/thickbox.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="css/LoadingStatus.css" type="text/css" />
	<style type="text/css" media="screen">
		@import url(css/niceforms.css);
	</style>
<%
	List items1 = new ArrayList();


	try {
		//conn = DriverManager.getConnection(connectionURL,"root","7742765"); 
		//st=conn.createStatement();
		ResultSet rs =conn.executeQuery("SELECT distinct big_id FROM bigitem order by big_id");
		while (rs.next())
		{
			items1.add(rs.getString(1));
		}
		//items1.add(2);
	}  catch (Exception e)  {   
		e.printStackTrace();
	}
%>
	<script type="text/javascript">
		$(document).ready(function(){
			$.NiceJForms.build()
		});
		
		function selectAll(chk)
		{
			var chk = document.form2.chkAll.checked;
			for (i=0;i<document.all.length;i++) {
				if (document.all[i].name=="list") {
					document.all[i].checked=chk;
					//chkRow(document.all[i]);
				}
			}
		}
	</script>
	
	<script language="javascript">
		var XMLHttpReq;//这个例子里面只用到一个XMLHttpRequest对象，用于获取服务端返回的XML序列
 		//创建XMLHttpRequest对象
    	function createXMLHttpRequest() {
		if(window.XMLHttpRequest) { //Mozilla 浏览器
			XMLHttpReq = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) { // IE浏览器
			try {
				XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
	}
	//发送请求函数
	function sendRequest1(url) {
		createXMLHttpRequest();
		XMLHttpReq.open("GET", url, true);
		XMLHttpReq.onreadystatechange = processResponse1;//指定响应函数
		XMLHttpReq.send(null);  // 发送请求
	}
	// 处理返回信息函数
    function processResponse1() {
    	if (XMLHttpReq.readyState == 4) { // 判断对象状态
        	if (XMLHttpReq.status == 200) { // 信息已经成功返回，开始处理信息
				updateList1();
		    } else { //页面不正常
		      	alert("您所请求的页面有异常。");
		    }
        }
    }
	//更新菜单函数
	function updateList1() {
	    var small_id=XMLHttpReq.responseXML.getElementsByTagName("small_id");
	    var list = document.all.list1;
        for(var i=0;i<small_id.length;i++){
        	list.add(new Option(small_id[i].firstChild.data,small_id[i].firstChild.data));
        }
	}
	
	//发送请求函数
	function sendRequest2(url) {
		createXMLHttpRequest();
		XMLHttpReq.open("GET", url, true);
		XMLHttpReq.onreadystatechange = processResponse2;//指定响应函数
		XMLHttpReq.send(null);  // 发送请求
	}
	// 处理返回信息函数
    function processResponse2() {
    	if (XMLHttpReq.readyState == 4) { // 判断对象状态
        	if (XMLHttpReq.status == 200) { // 信息已经成功返回，开始处理信息
				
				updateList2();
		    } else { //页面不正常
		      	alert("您所请求的页面有异常。");
		    }
        }
    }
	
	function updateList2() {
        var types=XMLHttpReq.responseXML.getElementsByTagName("type");
       	var list = document.all.list2;
        for(var i=0;i<types.length;i++){
        	list.add(new Option(types[i].firstChild.data,types[i].firstChild.data));
        }
	}
	// 创建级联菜单函数
	function showList1(obj) {
		clearList1();
    	clearList2();
		sendRequest1("financejsp.jsp?big_id=" + obj);
	}
	function showList2(obj) {
		clearList2();
		sendRequest2("financejsp.jsp?small_id="+obj);
	}

	function clearList1()
	{
		var list = document.all.list1;
		list.options.length=0;
    	list.add(new Option("---请选择---",""));
	}
	
	function clearList2()
	{
		var list = document.all.list2;
		list.options.length=0;
        list.add(new Option("---请选择---",""));
	}

</script>
	
</head>

<body>

		<div id="header">
			<div id="logo">
				<h1> 
					Daily 
				</h1>
				<h2>
				
				</h2>
			</div>
			<div id="menu">
				<ul>
					<li class="active">
						<a href="index.jsp" accesskey="1" title="">首页</a>
					</li>
					<li >
					    <a href='blog.jsp' accesskey="2" title="">博客</a>
					</li>
					<li>
						<a href="musicbox.jsp" accesskey="3" title="">音乐盒</a>
					</li>
					<li>
						<a href="message.jsp" accesskey="4" title="">短消息</a>
					</li>
					<li>
						<a href="uploadmusic.jsp" accesskey="5" title="">分享歌曲</a>
					</li>
					<li>
						<a href="player" accesskey="6" title="">播放列表</a>
					</li>
					<li>
						<a href="finance.jsp" accesskey="7" title="">个人财务</a>
					</li>
				</ul>
			</div>
		</div>
		
		<div id="LoadingStatus">
			<img src="images/ajax-loader.gif" />
		</div>
		<hr />
		
		<div id="page">
			<div id="bg">
				<div id="content">
					<div class="post">
						<h2 class="title">
							个人财务
						</h2>
		
	

<form>

<table border="0">
	<tr>
		<td><label for="类别">类别</label>
		</td>
		
		<td>
			<select onchange="showList1(this.options[this.options.selectedIndex].value)" name="mli"  style="width:150px">
			<option value=''>---请选择---</option>
			<%
			for(int i=0;i<items1.size();i++)
			{
				out.println("<option value='"+items1.get(i)+"'>"+items1.get(i)+"</option>");
			}
			%>
			</select>
		</td>
		<td>
		<select name="list1" onchange="showList2(this.options[this.options.selectedIndex].value)" style="width:150px">
		<option name="">---请选择---</option>
		</select>
 		</td>
 		<td><select name="list2" onchange="if(this.selectedIndex)alert(this.options[this.options.selectedIndex].value)" style="width:150px">
		<option name="">---请选择---</option>
		</select>
		</td>
	</tr>
	<tr>
	    <td><label for="金额">金额</label>
		</td>
		<td><input type=text t_value="" o_value="" onkeypress="if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value" onkeyup="if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value" onblur="if(!this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?|\.\d*?)?$/))this.value=this.o_value;else{if(this.value.match(/^\.\d+$/))this.value=0+this.value;if(this.value.match(/^\.$/))this.value=0;this.o_value=this.value}"></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
	<td><label for="日期">日期</label>
		</td>
		<td><input type="text"  class="input2" name="date1" id="startTime"  
			readonly="readonly" onClick="this.value='';fPopCalendar(this,this,this.value);return false;"/> </td>
		<td>&nbsp;</td><td>&nbsp;</td>
	</tr>
</table>

</form>

</div></div>
<!-- end contentn -->
				<div id="sidebar">
					<div id="about-box" style="font-size: 12px">
						
							<%
								if (session.getAttribute("PlutoUser") == null) {
							%>
						
						<form action="login.action" method="post" class="niceform">
							<label for="textinput">
								&nbsp;&nbsp;用户名：
							</label>
							<br/>
							&nbsp;&nbsp;
							<input type="text" id="textinput" name="userName" size="15"
								maxlength="16" />
							<br/>
							<label for="passwordinput">
								&nbsp;&nbsp;密 码：
							</label>
							<br/>
							&nbsp;&nbsp;
							<input type="password" id="passwordinput" name="userPwd"
								size="15" maxlength="16" />
							<br/>
							<br/>
							&nbsp;&nbsp;&nbsp;&nbsp;
							<input type="submit" value="登  陆" />&nbsp;&nbsp;
							<a href="register.jsp?height=175&width=300&modal=true"
								class="thickbox" title="我要注册">我要注册</a> 
						</form>


						<p></p>
						<%
							} else {
						%>
						<p>
							<%=session.getAttribute("PlutoUser").toString()%>，欢迎您回来！
						</p>
						<%
							String userName = session.getAttribute("PlutoUser").toString();
								ResultSet user_rs = conn
										.executeQuery("select id from user where name = '"
												+ userName + "'");
								user_rs.next();
								String id = user_rs.getString("id");
								ResultSet message_rs = conn
										.executeQuery("select count(id) as count from message where `to` ="
												+ id + " and `new` = 1");
								message_rs.next();
								int myMessage = message_rs.getInt("count");
						%>
						<p>
							您有<%=(myMessage==0)?(myMessage):("<font color=red><strong>" + myMessage + "</strong></font>")%>封未读短消息，请
							<a href="message.jsp" style="color: red">查看</a>！
							<br />
							播放我上次创建的
							<a href="player" style="color: red">[播放列表]</a>！
							<br />
							如果您有音乐分享，您可以点我进行
							<a href="uploadmusic.jsp" style="color: red">[上传音乐]</a>！
							<br />
						</p>
						<p>
							退出请点
							<a href="logout.action" style="color: #FF0000">[注销登陆]</a>！
						</p>
						<%
							}
						%>
					</div>
					<ul>
						<li>
							<h2>
								最新消息
							</h2>
							<ul>
								<%
									ResultSet tip_rs = conn
											.executeQuery("SELECT * FROM `tip` ORDER BY id DESC LIMIT 10");
									while (tip_rs.next()) {
										String tip = tip_rs.getString("value");
										out.println("<li>");
										out.println(tip);
										out.println("</li>");
									}
								%>

							</ul>
						</li>
						<li>
							<h2>
								友情链接
							</h2>
							<ul>
								<%
									ResultSet link_rs = conn
											.executeQuery("SELECT * FROM `link` ORDER BY id DESC LIMIT 20");
									while (link_rs.next()) {
										String link_title = link_rs.getString("title");
										String link_value = link_rs.getString("value");
										out.println("<li>");
										out.println("<a href=\""+link_value+"\">");
										out.println(link_title+"</a>");
										out.println("</li>");
									}
								%>
							</ul>
						</li>
					</ul>
				</div>
				<!-- end sidebar -->
				<div style="clear: both;">
					&nbsp;
				</div>
			</div>
		</div>
		</div>
		</div></div></div>
		<!-- end page -->
		<hr />
		<div id="footer">
			<p>
				(c) 2012 Daily
			</p>
		</div>
</body>
</html>